#include <X11/Xlib.h>
#include <stdio.h>
#include <err.h>

static Display *dpy;
static int screen;
static Window root;

#define POSX   (1920 - WIDTH)/2
#define POSY   (1080 - HEIGHT)/2
#define WIDTH  500
#define HEIGHT 500
#define BORDER 12

int main()
{
  // define our window for this program
  Window win;
  XEvent ev;

  if ((dpy = XOpenDisplay(NULL)) == NULL) {
    err(1, "Can't open display\n");
  }

  // get default screen and root window
  screen = DefaultScreen(dpy);
  root = RootWindow(dpy, screen);

  // create our simple window
  win = XCreateSimpleWindow(dpy, root, POSX, POSY, WIDTH, HEIGHT, BORDER, BlackPixel(dpy, screen), WhitePixel(dpy, screen));
  // map our simple window to display server
  XMapWindow(dpy, win);

  while (XNextEvent(dpy, &ev) == 0) {
    
  }

  // unmap our simple window
  XUnmapWindow(dpy, win);
  // free resources
  XDestroyWindow(dpy, win);
  // close connection with display server
  XCloseDisplay(dpy);

  return 0;
}
